<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
    xmlns:s="http://jboss.com/products/seam/taglib"
    xmlns:ui="http://java.sun.com/jsf/facelets"
    xmlns:f="http://java.sun.com/jsf/core"
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:a="http://richfaces.org/a4j"
    xmlns:rich="http://richfaces.org/rich"
    template="layout/template.xhtml">

<ui:define name="body">

    <h:form id="auditTrail" styleClass="edit">

        <rich:panel>
            <f:facet name="header">#{auditTrailHome.managed ? 'Edit' : 'Add'} Audit trail</f:facet>



            <s:decorate id="classNameField" template="layout/edit.xhtml">
                <ui:define name="label">Class name</ui:define>
                <h:inputTextarea id="className"
                               cols="80"
                               rows="3"
                              value="#{auditTrailHome.instance.className}"/>
            </s:decorate>


            <s:decorate id="endDateField" template="layout/edit.xhtml">
                <ui:define name="label">End date</ui:define>
                <rich:calendar id="endDate"
                          value="#{auditTrailHome.instance.endDate}" datePattern="MM/dd/yyyy hh:mm a"/>
            </s:decorate>


            <s:decorate id="methodNameField" template="layout/edit.xhtml">
                <ui:define name="label">Method name</ui:define>
                <h:inputTextarea id="methodName"
                               cols="80"
                               rows="3"
                              value="#{auditTrailHome.instance.methodName}"/>
            </s:decorate>


            <s:decorate id="startDateField" template="layout/edit.xhtml">
                <ui:define name="label">Start date</ui:define>
                <rich:calendar id="startDate"
                          value="#{auditTrailHome.instance.startDate}" datePattern="MM/dd/yyyy hh:mm a"/>
            </s:decorate>



            <div style="clear:both">
                <span class="required">*</span>
                required fields
            </div>

        </rich:panel>

        <div class="actionButtons">

            <h:commandButton id="save"
                          value="Save"
                         action="#{auditTrailHome.persist}"
                       disabled="#{!auditTrailHome.wired}"
                       rendered="#{!auditTrailHome.managed}"/>

            <h:commandButton id="update"
                          value="Save"
                         action="#{auditTrailHome.update}"
                       rendered="#{auditTrailHome.managed}"/>

            <h:commandButton id="delete"
                          value="Delete"
                         action="#{auditTrailHome.remove}"
                      immediate="true"
                       rendered="#{auditTrailHome.managed}"/>

            <s:button id="cancelEdit"
                   value="Cancel"
             propagation="end"
                    view="/AuditTrail.xhtml"
                rendered="#{auditTrailHome.managed}"/>

            <s:button id="cancelAdd"
                   value="Cancel"
             propagation="end"
                    view="/#{empty auditTrailFrom ? 'AuditTrailList' : auditTrailFrom}.xhtml"
                rendered="#{!auditTrailHome.managed}"/>

        </div>
    </h:form>

<rich:tabPanel switchType="ajax">

    <rich:tab label="User account">
    <div class="association" id="userAccountParent">

        <h:outputText value="There is no userAccount associated with this auditTrail."
                   rendered="#{auditTrailHome.instance.userAccount == null}"/>

        <rich:dataTable var="_userAccount"
                   value="#{auditTrailHome.instance.userAccount}"
                rendered="#{auditTrailHome.instance.userAccount != null}"
              rowClasses="rvgRowOne,rvgRowTwo"
                      id="userAccountTable">
            <h:column>
                <f:facet name="header">Id</f:facet>
                <h:outputText value="#{_userAccount.id}"/>
            </h:column>
            <h:column>
                <f:facet name="header">Enabled</f:facet>
                <h:outputText value="#{_userAccount.enabled}"/>
            </h:column>
            <h:column>
                <f:facet name="header">Password hash</f:facet>
                <h:outputText value="#{_userAccount.passwordHash}"/>
            </h:column>
            <h:column>
                <f:facet name="header">Username</f:facet>
                <h:outputText value="#{_userAccount.username}"/>
            </h:column>
        </rich:dataTable>

        <div class="actionButtons">
            <s:button id="#{auditTrailHome.instance.userAccount != null ? 'changeParent' : 'selectParent'}" value="#{auditTrailHome.instance.userAccount != null ? 'Change' : 'Select'} userAccount"
                       view="/UserAccountList.xhtml">
                <f:param name="from" value="AuditTrailEdit"/>
            </s:button>
        </div>

    </div>
    </rich:tab>
</rich:tabPanel>
</ui:define>

</ui:composition>
